package com.gt.quality.apim.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/**
 * @author Administrator
 */
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Data
@TableName(value = "api_param_relationship_interface", autoResultMap = true)
public class ApiRelationshipInterfaceInfo extends Model<ApiRelationshipInterfaceInfo> implements Serializable {

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @Schema(title = "id", description = "主键id")
    @JsonSerialize(using= ToStringSerializer.class)
    private Long id;

    @TableField(value = "api_id")
    @Schema(title = "api_id", description = "API主表Id")
    private Long apiId;

    @TableField(value = "api_name")
    @Schema(title = "api_name", description = "API名称")
    private String apiName;

    /**
     * JSON请求报文体
     */
    @TableField(value = "param_default_value")
    @Schema(title = "param_default_value", description = "参数的值")
    private String paramDefaultValue;

    @TableField(value = "param_json_path")
    @Schema(title = "param_json_path", description = "接口的值JSONPath取值")
    private String paramJsonPath;

    @TableField(value = "create_time", fill = FieldFill.INSERT)
    @Schema(title = "create_time", description = "创建时间")
    private Date createTime;

    public Date getCreateTime() {
        if (createTime == null) {
            createTime = new Date();
        }
        return createTime;
    }

    public Date getUpdateTime() {
        if (updateTime == null) {
            updateTime = new Date();
        }
        return updateTime;
    }

    @TableField(value = "create_by")
    private Long createBy;

    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    @Schema(title = "update_time", description = "修改时间")
    private Date updateTime;

    @TableField(value = "update_by")
    private Long updateBy;

    @TableField(value = "delete_flag")
    @TableLogic(delval = "1", value = "0")
    private Integer deleteFlag;

    public Integer getDeleteFlag() {
        if (deleteFlag == null) {
            deleteFlag = 0;
        }
        return deleteFlag;
    }

    @TableField(value = "create_dept")
    private Long createDept;

}
